﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Web.Mvc;
//using System.Web;
//using System.Web.Routing;
//using Microsoft.VisualStudio.TestTools.UnitTesting;
//using LOMBARDISPICK.Web;
//using LOMBARDISPICK.Web.Controllers;
//using LOMBARDISPICK.Domain.Services;
//using Moq;
//using System.IO;
//using System.Security.Principal;
//using LOMBARDISPICK.Tests.Infrastructure;
//using System.DirectoryServices.AccountManagement;
//using FluentAssertions.Assertions;
//using FluentAssertions.Common;
//using FluentAssertions.EventMonitoring;
//using FluentAssertions.Formatting;
//using FluentAssertions;

//namespace LOMBARDISPICK.Tests.Controllers
//{
//    [TestClass]
//    public class LogonControllerTests
//    {
//        [TestMethod]
//        public void LogonWithOneRole()
//        {
//            //
//            // Arrange
//            // manual mocking of objects
//            var EmployeeService = new Mock<IEMPLOYEEService>();
//            var AppUserRoleService = new Mock<IAPP_USER_ROLEService>();
//            var EmployeePreferencesService = new Mock<IEMPLOYEE_PREFERENCESService>();
//            var EmployeeLoginLogService = new Mock<IEMPLOYEE_LOGIN_LOGService>();
//            //useful vars for mocking
//            List<String> userRolesList = new List<String>();
//            userRolesList.Add("OneRole");
//            var myList = new SelectListItem[] { new SelectListItem { Value = "1", Text = "OneRole" } };
//            AppUserRoleService.Setup(x => x.ExamineUsersGroupsCreatingNewGroupPrincipalRecords(It.IsAny<PrincipalSearchResult<Principal>>())).Returns(userRolesList);
//            AppUserRoleService.Setup(x => x.getWritePermissionRolesForUser(userRolesList)).Returns(myList);
//            //mock controller
//            var controller = new LOGONController(EmployeeService.Object, AppUserRoleService.Object, EmployeePreferencesService.Object, EmployeeLoginLogService.Object);
//            //setup HttpContext
//            MvcMockHelpers.SetFakeControllerContext(controller);
//            //
//            // Act
//            RedirectToRouteResult result = controller.Index() as RedirectToRouteResult;
//            //
//            // Assert
//            result.RouteValues.Values.First().Should().Be("Index");
//            result.RouteValues.Values.Last().Should().Be("home");
//        }

//        [TestMethod]
//        public void LogonWithMultipleRoles()
//        {
//            var EmployeeService = new Mock<IEMPLOYEEService>();
//            var AppUserRoleService = new Mock<IAPP_USER_ROLEService>();
//            var EmployeePreferencesService = new Mock<IEMPLOYEE_PREFERENCESService>();
//            var EmployeeLoginLogService = new Mock<IEMPLOYEE_LOGIN_LOGService>();
//            //useful vars for mocking
//            List<String> userRolesList = new List<String>();
//            userRolesList.Add("FirstRole");
//            userRolesList.Add("SecondRole");
//            var myList = new SelectListItem[] { new SelectListItem { Value = "1", Text = "FirstRole" }, new SelectListItem { Value = "2", Text = "SecondRole" } };
//            AppUserRoleService.Setup(x => x.ExamineUsersGroupsCreatingNewGroupPrincipalRecords(It.IsAny<PrincipalSearchResult<Principal>>())).Returns(userRolesList);
//            AppUserRoleService.Setup(x => x.getWritePermissionRolesForUser(userRolesList)).Returns(myList);
//            //mock controller
//            var controller = new LOGONController(EmployeeService.Object, AppUserRoleService.Object, EmployeePreferencesService.Object, EmployeeLoginLogService.Object);
//            //setup HttpContext
//            MvcMockHelpers.SetFakeControllerContext(controller);
//            //
//            // Act
//            ViewResult result = controller.Index() as ViewResult;
//            //
//            // Assert
//            result.ViewName.Should().Be("ForceUserToChooseOneRole");
//            result.ViewData.Model.Should().BeOfType<LOMBARDISPICK.Model.LOGONModel>();
//        }

//        [TestMethod]
//        public void LogonWithNoRolesSeeFailure()
//        {
//            //
//            // Arrange
//            // manual mocking of objects
//            var EmployeeService = new Mock<IEMPLOYEEService>();
//            var AppUserRoleService = new Mock<IAPP_USER_ROLEService>();
//            var EmployeePreferencesService = new Mock<IEMPLOYEE_PREFERENCESService>();
//            var EmployeeLoginLogService = new Mock<IEMPLOYEE_LOGIN_LOGService>();
//            //useful vars for mocking
//            List<String> userRolesList = new List<String>();
//            userRolesList = null;
//            var myList = new SelectListItem[] {};
//            AppUserRoleService.Setup(x => x.ExamineUsersGroupsCreatingNewGroupPrincipalRecords(It.IsAny<PrincipalSearchResult<Principal>>())).Returns(userRolesList);
//            AppUserRoleService.Setup(x => x.getWritePermissionRolesForUser(userRolesList)).Returns(myList);
//            //mock controller
//            var controller = new LOGONController(EmployeeService.Object, AppUserRoleService.Object, EmployeePreferencesService.Object, EmployeeLoginLogService.Object);
//            //setup HttpContext
//            MvcMockHelpers.SetFakeControllerContext(controller);
//            //
//            // Act
//            ViewResult result = controller.Index() as ViewResult;
//            //
//            // Assert
//            result.ViewName.Should().Be("MissingValidActiveDirectoryRoles");
//        }


//        [TestMethod]
//        public void LogonWithUnauthenticatedSeeFailure()
//        {
//            //
//            // Arrange
//            // manual mocking of objects
//            var EmployeeService = new Mock<IEMPLOYEEService>();
//            var AppUserRoleService = new Mock<IAPP_USER_ROLEService>();
//            var EmployeePreferencesService = new Mock<IEMPLOYEE_PREFERENCESService>();
//            var EmployeeLoginLogService = new Mock<IEMPLOYEE_LOGIN_LOGService>();
//            //mock controller
//            var controller = new LOGONController(EmployeeService.Object, AppUserRoleService.Object, EmployeePreferencesService.Object, EmployeeLoginLogService.Object);
//            //setup HttpContext
//            //setup HttpContext
//            controller.ControllerContext = new ControllerContext();
//            controller.ControllerContext.HttpContext = MvcMockHelpers.FakeHttpContext("~/");
//            //
//            // Act
//            ViewResult result = controller.Index() as ViewResult;
//            //
//            // Assert
//            result.ViewName.Should().Be("NotAuthenticated");
//        }
//    }
//}
